package me.yushuai.wukong.base.entity;

import lombok.*;
import org.hibernate.annotations.Type;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;

/**
 * 包规单位
 * <p>
 * https://en.wikipedia.org/wiki/TI-HI
 * https://baijiahao.baidu.com/s?id=1675716885151517559&wfr=spider&for=pc
 * https://baike.baidu.com/item/%E6%89%98%E7%9B%98/1646740
 *
 * @author zhoushuai@189.cn
 * @TableName BAS_PACKING_DETAILS
 */
@Entity
@Getter
@Setter
@ToString
@Table(name = "BAS_PACKING_UOM")
public class PackingUom implements Serializable {

    /**
     * 单位编号
     */
    @Id
    @Column(name = "UOM_ID")
    private Long uomId;

    /**
     * 单位编码
     */
    @Column(name = "BIZ_ID", nullable = false, updatable = false)
    private String bizId;

    /**
     * 包装代码
     */
    @Column(name = "PACKING_ID", nullable = false, updatable = false)
    private Long packingId;


    /**
     * 基本单位
     */
    @Type(type = "yes_no")
    @Column(name = "BASIC_UNIT", updatable = false, nullable = false)
    private Boolean basicUnit;

    /**
     * 中文描述
     */
    @Column(name = "DESC_CH")
    private String descCh;

    /**
     * 英文描述
     */
    @Column(name = "DESC_EN")
    private String descEn;

    /**
     * 数量
     */
    @Column(name = "QTY")
    private BigDecimal qty;

    /**
     * 装箱
     */
    @Column(name = "CARTONIZE_UOM")
    private String cartonizeUom;

    /**
     * 包材
     */
    @Column(name = "PACK_MATERIAL")
    private String packMaterial;

    /**
     * 体积
     */
    @Column(name = "CUBE_UOM")
    private Integer cubeUom;

    /**
     * 高
     */
    @Column(name = "HEIGHT_UOM")
    private Integer heightUom;

    /**
     * 长
     */
    @Column(name = "LENGTH_UOM")
    private Integer lengthUom;

    /**
     * 重量
     */
    @Column(name = "WEIGHT_UOM")
    private Integer weightUom;

    /**
     * 宽
     */
    @Column(name = "WIDTH_UOM")
    private Integer widthUom;

    /**
     * 入库标签是用于表示当前包规单位是否可以作为上架的单位
     */
    @Type(type = "yes_no")
    @Column(name = "IN_LABEL")
    private Boolean inLabel;

    /**
     * 出库标签
     */
    @Type(type = "yes_no")
    @Column(name = "OUT_LABEL")
    private Boolean outLabel;

    /**
     * 补货标记
     */
    @Type(type = "yes_no")
    @Column(name = "RPL_LABEL")
    private Boolean rplLabel;


    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        PackingUom that = (PackingUom) o;
        return Objects.equals(getUomId(), that.getUomId()) && Objects.equals(getBizId(), that.getBizId()) && Objects.equals(getPackingId(), that.getPackingId()) && Objects.equals(getBasicUnit(), that.getBasicUnit()) && Objects.equals(getDescCh(), that.getDescCh()) && Objects.equals(getDescEn(), that.getDescEn()) && Objects.equals(getQty(), that.getQty()) && Objects.equals(getCartonizeUom(), that.getCartonizeUom()) && Objects.equals(getPackMaterial(), that.getPackMaterial()) && Objects.equals(getCubeUom(), that.getCubeUom()) && Objects.equals(getHeightUom(), that.getHeightUom()) && Objects.equals(getLengthUom(), that.getLengthUom()) && Objects.equals(getWeightUom(), that.getWeightUom()) && Objects.equals(getWidthUom(), that.getWidthUom()) && Objects.equals(getInLabel(), that.getInLabel()) && Objects.equals(getOutLabel(), that.getOutLabel()) && Objects.equals(getRplLabel(), that.getRplLabel());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getUomId(), getBizId(), getPackingId(), getBasicUnit(), getDescCh(), getDescEn(), getQty(), getCartonizeUom(), getPackMaterial(), getCubeUom(), getHeightUom(), getLengthUom(), getWeightUom(), getWidthUom(), getInLabel(), getOutLabel(), getRplLabel());
    }


}
